use List::Util 'shuffle';
open FILE, "<$ARGV[0]";
open OUT1, ">$ARGV[1]";
open OUT2, ">$ARGV[2]";
open OUT3, ">$ARGV[3]";


$size = 0;
@list = ();
@data = ();

while (<FILE>)
{
    push @data, $_;
    $size ++;
};

close FILE;

@shuffled = shuffle(@data);

for ($i = 0; $i < $size; ++$i)
{
    if ($i< $size / 5) {
        $x = $shuffled[$i];
        $x =~ s/^(.*)\:\s+//;
        print OUT1 "$x";
        print OUT3 "$1\n";
    }
    else {
        print OUT2 "$shuffled[$i]";
    };
};

close OUT1;
close OUT2; 
close OUT3;
